package com.example.spring.code.a01;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import java.util.logging.Logger;

@Component
public class Component1 {

    private static final Logger log = Logger.getLogger(Component1.class.getName());

    @Autowired
    private ApplicationContext context;

    public void register() {
        log.info("用户注册");
        context.publishEvent(new UserRegisteredEvent(this));
    }
}
